/** 
 * @ProjectName: platform
 * @FileName: LoginByForm.js
 * @PackageName:  webapp/app/view/protal/authentication
 * @Description: (用一句话描述该文件做什么) 
 * @Author :  JasonWu (15909910367@163.com)
 * @Date:  2021年10月26日 
 * @Copyright (c) 2020-2025, 15909910367@163.com All Rights Reserved. 
 * 
 */
Ext.define('Jason.view.protal.authentication.LoginByForm', {
    extend: 'Ext.container.Container',
    xtype: 'loginByForm',
    alternateClassName: 'loginByForm',
    requires: [
        'Ext.Component',
        'Wys.form.field.CheckCode',
        'Jason.view.protal.authentication.Register',
        'Jason.view.protal.authentication.AuthenticationModel',
        'Jason.view.protal.authentication.Dialog',
        'Ext.container.Container',
        'Ext.form.field.Text',
        'Wys.locale.Locale',
        'Jason.store.ReqUrl',
        'Ext.form.field.Checkbox',
        'Ext.button.Button',
        'Jason.view.protal.authentication.AuthenticationController'
    ],
    controller: 'authentication',
    viewModel: { type: 'authentication' },
    title: I18N.LoginTitle,
    cls: 'auth-dialog',
    layout: {
		type:'hbox',
		padding:'0 50 0 0 ',
		pack:'end',
		align:'middle'
	},
	listeners:{
		afterrender:function(mainView){
			mainView.up('card-layout-panel').setStyle({
				'background': 'url(resources/images/login-bg.173ae8f5.jpg)  no-repeat 50%',
				'background-size': 'cover'
			});
		}
	},
    defaultFocus: 'authdialog',
    items: [
        {
            xtype: 'form', style: 'border:1px solid #dfe1e6;border-radius:6px;',
            defaultButton: 'loginButton',
            autoComplete: true,
            bodyPadding: '20 20',
            pack:'end',align:'stretch',
            cls: 'auth-dialog-login',
            header: false,
            bodyStyle:{'right':'20px;'},
            width: 400,
            layout: {
                type: 'vbox',
                pack: 'right',
                align: 'stretch'
            },

            defaults: {
                margin: '5 0'
            },

            items: [
                {
                    xtype: 'label',
                    html: '<fieldset style="border-color: #c5c5c5;border-width: 1px 0 0;border-style: solid;">' +
                        '	<legend style="margin-left: 20px;padding: 0 10px;font-size: 20px;font-weight: 300;color:#333;">' +
                        I18N.LoginLabel
                        + '</legend>' +
                        '</fieldset>'
                },
                {
                    xtype: 'textfield',
                    cls: 'auth-textbox',
                    name: 'loginName',
                    bind: '{userid}',
                    height: 55,
                    hideLabel: true,
                    allowBlank: false,
                    emptyText: I18N.UserId,
                    listeners: {
                        specialkey: function (field, e) {
                            if (e.getKey() == Ext.EventObject.ENTER) {
                                field.up().down('textfield[name=password]').focus(true, false);
                            }
                        }
                    },
                    triggers: {
                        glyphed: {
                            cls: 'trigger-glyph-noop auth-email-trigger'
                        }
                    }
                },
                {
                    xtype: 'textfield',
                    cls: 'auth-textbox',
                    height: 55,
                    hideLabel: true,
                    emptyText: I18N.Password,
                    inputType: 'password',
                    name: 'password',
                    bind: '{password}',
                    allowBlank: false,
                    triggers: {
                        glyphed: {
                            cls: 'trigger-glyph-noop auth-password-trigger'
                        }
                    }
                },{
                	xtype : 'fieldVerify',
                	codeImgUrl : reqUrl.sys.captchaCode,
                	//文本框配置
		            textfield: {
		                name: 'captcha',
		                msgTarget: 'qtip'
		            },
		            //文本框内置按钮
		            refresh: {
		                cls: 'auth-envelope-trigger fa-refresh'
		            }
                }, {
                    xtype: 'container',
                    layout: 'hbox',
                    items: [
                        {
                            xtype: 'checkboxfield',
                            flex: 1,name:'remeberMe',
                            style: 'border:0px;',
                            reference: 'remeberCheckBox',
                            cls: 'form-panel-font-color rememberMeCheckbox',
                            height: 30,
                            listeners: { change: 'onPersistChange' },
                            bind: '{persist}',
                            boxLabel: I18N.RememberMe
                        },
                        {
                            xtype: 'container',
                            style: {
                                padding: '8px 0px'
                            },
                            html: '没有账号，<a href="#register">注册</a>一个帐户',
                            listeners: {
                                el: {
                                    click: function (e) {
                                        console.log(e);
                                    }
                                }
                            }
                        }
                    ]
                },
                {
                    xtype: 'button',
                    reference: 'loginButton',
                    itemId: 'loginButton',
                    scale: 'large',
                    style: {
                        background: '#3177fd',
                        borderColor: '#3177fd',
                        borderRadius: '6px'
                    },
                    ui: 'soft-green',
                    iconAlign: 'right',
                    text: I18N.LoginTitle,
                    formBind: true,
                    listeners: {
                        click: 'onLoginButton'
                    }
                }
            ]
        }, {
            xtype: 'component',
            itemId: 'globalToast',
            floating: true,
            y: 10,
            shadow: false,
            hideMode: 'offsets',
            cls: 'global-toast',
            showAnimation: 'slideIn',
            html: ''
        }
    ],

    initComponent: function () {
        this.addCls('user-login-register-container');
        this.callParent(arguments);
    }
});
